import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    count: 0,
    globalData: {
      comment: 'shop',
      desc: '高铁订餐'
    },
    defaultAddress: {},
    user: {},
    cartNum: 0,
    curGoods: [],
    train: {}
  },
  mutations: {
    increment(state) {
      state.count++
    },
    updateDefaultAddress(state, address) {
      state.defaultAddress = address
    },
    setUser(state, user) {
      state.user = user
    },
    setCartNum(state, payload) {
      state.cartNum = payload
    },
    // 直接支付时保存的商品
    setCurGoods(state, payload) {
      state.curGoods = payload
    },
    setTrain(state, payload) {
      state.train = payload
    }
  }
})
export default store
